home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / mus / play / tracker_4_31.lzh / tracker / Amiga / wb2cli.h < prev   
C/C++ Source or Header  |  1995-01-13  |  5KB  |  150 lines

  1. /*
  2.  * $Id: wb2cli.h,v 1.1 1995/01/13 13:31:35 espie Exp espie $
  3.  *
  4.  * $Log: wb2cli.h,v $
  5.  * Revision 1.1  1995/01/13  13:31:35  espie
  6.  * Initial revision
  7.  *
  8.  * Revision 1.1  1994/06/22  21:54:12  Espie
  9.  * Initial revision
  10.  *
  11.  * Revision 1.7  92/02/11  12:24:34  mks
  12.  * Slight wording change
  13.  * 
  14.  * Revision 1.6  92/02/11  12:14:19  mks
  15.  * Minor doc change
  16.  *
  17.  * Revision 1.5  91/12/30  18:22:28  mks
  18.  * Cleaned up the docs a bit...
  19.  *
  20.  * Revision 1.4  91/07/24  20:03:29  mks
  21.  * Autodoc cleanup
  22.  *
  23.  * Revision 1.2  91/07/24  18:58:42  mks
  24.  * Forgot to fix the example to use default stack.
  25.  *
  26.  * Revision 1.1  91/07/24  18:57:46  mks
  27.  * Added the defaultstack to the prototype and documentation.
  28.  *
  29.  * Revision 1.0  91/07/24  17:03:24  mks
  30.  * Initial revision
  31.  *
  32.  */
  33.  
  34. /*
  35.  * WB2CLI - By Michael Sinz
  36.  *             Operating System Development Group
  37.  *             Commodore-Amiga, Inc.
  38.  *
  39.  * This is the magic code needed to take a started workbench process
  40.  * and convert it into a CLI process with a copy of the workbench path.
  41.  *
  42.  * After that point, the process will look much like a background CLI.
  43.  */
  44.  
  45. /*
  46. ******* WB2CLI ***************************************************************
  47. *
  48. *   NAME
  49. *    WB2CLI                                (V37)
  50. *
  51. *   SYNOPSIS
  52. *    status = WB2CLI(wbmsg,defaultstack,dosbase)
  53. *      D0             A0    D0           A1
  54. *
  55. *    LONG WB2CLI(struct WBStartup *,ULONG,struct DosLibrary *)
  56. *
  57. *   FUNCTION
  58. *    This function will take a workbench started application and change
  59. *    it into a CLI-like application.  This will include a path as copied
  60. *    from the Workbench.  The CLI default stack is used to pick the stack
  61. *    size for the processes run as CLIs.  (This is in SYNC mode)
  62. *
  63. *    You would pass in the Workbench message pointer and a pointer
  64. *    to an open dos.library.  (The DosLibrary pointer is used to call
  65. *    dos.library without the need of globals.)
  66. *
  67. *    This *REQUIRES* V37 dos.library and exec.library.
  68. *
  69. *   NOTES
  70. *    Assembly language programmers:  This routine is _WB2CLI
  71. *
  72. *    If you call WB2CLI() and are already a CLI, it will return as if
  73. *    it worked even though it did nothing.  (After all, you were a CLI)
  74. *    For this reason, you do not need to check if you are a CLI
  75. *    started program before you call the function.
  76. *
  77. *    One word of interest:  Once you call this function, the pr_CLI
  78. *    field of your process will *NOT* be NULL.  This is by definition
  79. *    of what this program is trying to do, which is make you like a CLI.
  80. *    You will, however, still need to reply the workbench startup message
  81. *    that you passed to the WB2CLI routine.
  82. *
  83. *    You are, however, responsible for setting up any input or output
  84. *    file handles that you may needed.  Being workbench started means
  85. *    that you have no standard-in or standard-out.  (Just as before)
  86. *    (In other words, this function does not magically give you any
  87. *    I/O as you may already have done so or need a special form of it)
  88. *    These handles are pr_CIS, pr_COS, etc.  For example, many DOS
  89. *    calls may rely on these being valid.  RunCommand() under V37
  90. *    is one such creature.
  91. *
  92. *   EXAMPLE
  93. *    void main(int argc, char *argv[])
  94. *    {
  95. *    struct  DosLibrary  *DOSBase;
  96. *
  97. *        \* We need V37 to do this *\
  98. *        if (DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",37L))
  99. *        {
  100. *        \* Cute trick:  If you are a CLI, WB2CLI is a NO-OP *\
  101. *        \* Thus, you normally don't need to check *\
  102. *            \* NOTE:  Most of the time you will ignore the error *\
  103. *            if (WB2CLI((struct WBStartup *)argv,4000,DOSBase))
  104. *            {
  105. *                \* We now are workbench started CLI *\
  106. *                \* (Complete with path *\
  107. *            }
  108. *            else
  109. *            {
  110. *                \* We did not become a CLI but we still *\
  111. *                \* can run.  Just not as a CLI *\
  112. *            }
  113. *
  114. *            \* More stuff *\
  115. *
  116. *            CloseLibrary((struct Library *)DOSBase);
  117. *        }
  118. *    }
  119. *
  120. *   INPUTS
  121. *    wbmsg -- The Workbench message that you were started with.  If NULL
  122. *             this routine will do nothing...
  123. *
  124. *    defaultstack -- The size of the CLI default stack in bytes.
  125. *                    You *SHOULD* supply a value of at least 4000.
  126. *
  127. *    dosbase -- Pointer to dos.library (must be open)
  128. *
  129. *   RESULTS
  130. *    A magically transformed process that has a CLI structure added.
  131. *
  132. *    status -- Returns TRUE if it worked.  Usually can be ignored
  133. *              as your program will continue to work as if you did not
  134. *              call this function.
  135. *
  136. *   SEE ALSO
  137. *    None
  138. *
  139. *   BUGS
  140. *
  141. ******************************************************************************
  142. */
  143.  
  144. #include    <dos/dosextens.h>
  145. #include    <workbench/startup.h>
  146.  
  147. LONG __asm WB2CLI(register __a0 struct WBStartup *wbmsg,
  148.    register __d0 ULONG defaultstack, 
  149.    register __a1 struct DosLibrary *dosbase);
  150.